package com.lanchetech.dao;

import com.lanchetech.bean.request.AfterSalePageReq;
import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.request.SpuSellStatisticsReq;
import com.lanchetech.bean.request.TimeRangeReq;
import com.lanchetech.bean.response.AfterSaleResp;
import com.lanchetech.bean.vo.SpuSellStatisticsVO;
import com.lanchetech.bean.vo.StatisticsVO;
import com.lanchetech.entity.AfterSale;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Mapper
public interface AfterSaleMapper {
    int deleteByPrimaryKey(Long id);

    int insert(AfterSale record);

    int insertSelective(AfterSale record);

    AfterSale selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(AfterSale record);

    int updateByPrimaryKey(AfterSale record);

    AfterSale findOneByOrderSkuIdAndUserId(@Param("orderSkuId") Long orderSkuId, @Param("userId") Long userId);

    AfterSale findOneByIdAndUserId(@Param("id") Long id, @Param("userId") Long userId);

    int updateStatusAndUpdatedAtById(@Param("updatedStatus") Byte updatedStatus, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("id") Long id);

    List<AfterSaleResp> findAllFrontPage(PageReq req);

    List<AfterSale> findAllByIds(@Param("ids") List<Long> ids);

    List<AfterSaleResp> findAllBackPage(AfterSalePageReq req);

    AfterSale findOneByRefundNo(@Param("refundNo") String refundNo);

    int updateStatusByRefundNo(@Param("updatedStatus") Byte updatedStatus, @Param("refundNo") String refundNo);

    Long countByUserIdAndStatus(@Param("userId") Long userId);

    Long countByUserIdAndStatusAndOrderType(@Param("userId") Long userId, @Param("orderType") Byte orderType);

    Long countByStatus(@Param("status") Byte status);

    BigDecimal sumByStatusAndTenantId(@Param("status") Byte status, @Param("tenantId") Long tenantId);

    Long countByStatusAndTenantId(@Param("status") Byte status, @Param("tenantId") Long tenantId);

    SpuSellStatisticsVO getSpuRefundStatistics(SpuSellStatisticsReq req);

    BigDecimal getShopStatisticsData(TimeRangeReq req);

    List<StatisticsVO> getSpuRefundTrend(@Param("req") TimeRangeReq req, @Param("tenantId") Long shopId);
}